<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
  <title>视频发布</title>
</head>
<body>

  <!--导航-->
  <nav th:replace="admin/_fragments :: menu(4)"></nav>

  <!--中间内容-->
  <div  class="m-container m-padded-tb-big">
    <div class="ui container">
      <form id="video-form" th:object="${video}" th:action="@{/admin/addOrUpdateVideo}" method="post" class="ui form">
        <input type="hidden" name="id" th:value="*{id}">
        <div class="required field">
          <div class="ui left labeled input">
            <input type="text" name="name" placeholder="视频标题" th:value="*{name}">
          </div>
        </div>
        <div class="required field">
          <div id="md-content" style="z-index: 1 !important;">
            <textarea placeholder="视频内容" name="content" style="display: none" th:text="*{content}"></textarea>
          </div>
        </div>
        <div class="required field">
          <div class="ui left labeled input">
            <label class="ui teal basic label">视频首图</label>
            <input type="text" name="picture" th:value="*{picture}" placeholder="视频首图">
          </div>
        </div>
        <div class="required field">
          <div class="ui left labeled input">
            <label class="ui teal basic label">视频时长</label>
            <input type="text" name="time" th:value="*{time}" placeholder="视频时间">
          </div>
        </div>
        <div class="required field">
          <div class="ui left labeled input">
            <label class="ui teal basic label">视频标签</label>
            <input type="text" name="tag" th:value="*{tag}" placeholder="视频标签">
          </div>
        </div>
        <div class="required field">
          <div class="ui left labeled input">
            <label class="ui teal basic label">视频价格</label>
            <input type="text" name="price" th:value="*{price}" placeholder="视频加个">
          </div>
        </div>

        <div class="ui error message"></div>

        <div class="ui right aligned container">
          <button type="button" class="ui button" onclick="window.history.go(-1)" >返回</button>
          <button type="button" id="publish-btn" class="ui teal button">提交</button>
        </div>

      </form>
    </div>
  </div>

  <br>
  <br>
  <!--底部footer-->
  <footer th:replace="admin/_fragments :: footer"></footer>

  <!--/*/<th:block th:replace="admin/_fragments :: script">/*/-->
  <!--/*/</th:block>/*/-->


  <script>

    //初始化Markdown编辑器
    var contentEditor;
    $(function() {
      contentEditor = editormd("md-content", {
        width   : "100%",
        height  : 640,
        syncScrolling : "single",
//        path    : "../static/lib/editormd/lib/"
        path    : "/lib/editormd/lib/"
      });
    });
    $('.menu.toggle').click(function () {
      $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
      on : 'hover'
    });


    $('#publish-btn').click(function () {
      $('#video-form').submit();
    });



    $('.ui.form').form({
      fields : {
        name : {
          identifier: 'name',
          rules: [{
            type : 'empty',
            prompt: '标题：请输入视频标题'
          }]
        },
        content : {
          identifier: 'content',
          rules: [{
            type : 'empty',
            prompt: '标题：请输入视频内容'
          }]
        },
          time : {
          identifier: 'time',
          rules: [{
            type : 'empty',
            prompt: '标题：请输入视频时间'
          }]
        },
          picture : {
          identifier: 'picture',
          rules: [{
            type : 'empty',
            prompt: '标题：请输入视频首图'
          }]
        },
          tag : {
          identifier: 'tag',
          rules: [{
            type : 'empty',
            prompt: '标题：请输入视频标签'
          }]
        },
          price : {
              identifier: 'price',
              rules: [{
                  type : 'empty',
                  prompt: '标题：请输入视频价格'
              }]
          }
      }
    });

  </script>
</body>
</html>